<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改课程')" />
    <th:block th:include="include :: summernote-css" />
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: summernote-css" />
    <th:block th:include="include :: bootstrap-select-css" />
    <th:block th:include="include :: bootstrap-select-js" />
    <link href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="http://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-course-edit" th:object="${featherCourse}">
            <input name="courseId" th:field="*{courseId}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">选择分类：</label>
                <select name="specialIds" class="selectpicker" multiple data-live-search="true" title="请选择">
                    <option th:each="item:${specialList}" th:value="${item.specialId}" th:text="${item.specialName}"></option>
                </select>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">课程标题：</label>
                <div class="col-sm-8">
                    <input name="courseTitle" th:field="*{courseTitle}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否对外：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('feather_course_foreign')}">
                        <input type="radio" th:id="${'foreign_' + dict.dictCode}" name="foreign" th:value="${dict.dictValue}" th:field="*{foreign}">
                        <label th:for="${'foreign_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">是否免费：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('feather_course_free')}">
                        <input type="radio" th:id="${'free_' + dict.dictCode}" name="free" th:value="${dict.dictValue}" th:field="*{free}" required>
                        <label th:for="${'free_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否打折：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('feather_course_discount')}">
                        <input type="radio" th:id="${'discount_' + dict.dictCode}" name="discount" th:value="${dict.dictValue}" th:field="*{discount}">
                        <label th:for="${'discount_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">课程价格：</label>
                <div class="col-sm-8">
                    <input name="coursePrice" th:field="*{coursePrice}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">折后价：</label>
                <div class="col-sm-8">
                    <input name="discountPrice" th:field="*{discountPrice}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">降价描述：</label>
                <div class="col-sm-8">
                    <input name="priceDescription" th:field="*{priceDescription}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">课程副标题：</label>
                <div class="col-sm-8">
                    <input name="courseSubtitle" th:field="*{courseSubtitle}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">课程简介：</label>
                <div class="col-sm-8">
                    <input type="hidden" class="form-control" th:field="*{courseIntroduction}">
                    <div class="summernote" id="courseIntroduction"></div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">课程难度：</label>
                <div class="col-sm-8">
                    <select name="courseDifficulty" class="form-control m-b" th:with="type=${@dict.getType('feather_course_difficulty')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{courseDifficulty}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">排序：</label>
                <div class="col-sm-8">
                    <input name="sort" th:field="*{sort}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否轮播：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('feather_course_carousel')}">
                        <input type="radio" th:id="${'carousel_' + dict.dictCode}" name="carousel" th:value="${dict.dictValue}" th:field="*{carousel}">
                        <label th:for="${'carousel_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否精品推荐：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('feather_course_recommend')}">
                        <input type="radio" th:id="${'recommend_' + dict.dictCode}" name="recommend" th:value="${dict.dictValue}" th:field="*{recommend}">
                        <label th:for="${'recommend_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">封面路径：</label>
                <div class="col-sm-8">
                    <input name="courseCover" th:field="*{courseCover}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">轮播图路径：</label>
                <div class="col-sm-8">
                    <input name="carouselMap" th:field="*{carouselMap}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">电脑端轮播图路径：</label>
                <div class="col-sm-8">
                    <input name="pcCarouselMap" th:field="*{pcCarouselMap}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否展示详情：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('feather_course_show_details')}">
                        <input type="radio" th:id="${'showDetails_' + dict.dictCode}" name="showDetails" th:value="${dict.dictValue}" th:field="*{showDetails}">
                        <label th:for="${'showDetails_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">课程详情介绍路径：</label>
                <div class="col-sm-8">
                    <input name="courseDetails" th:field="*{courseDetails}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">播放量：</label>
                <div class="col-sm-8">
                    <input name="playVolume" th:field="*{playVolume}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">上线状态：</label>
                <div class="col-sm-8">
                    <select name="courseStatus" class="form-control m-b" th:with="type=${@dict.getType('feather_course_status')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{courseStatus}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: summernote-js" />
    <script th:inline="javascript">
        var prefix = ctx + "cloudcourse/course";
        $("#form-course-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-course-edit').serialize());
            }
        }

        $(function() {
            $('.summernote').each(function(i) {
                $('#' + this.id).summernote({
                    lang: 'zh-CN',
                    callbacks: {
                        onChange: function(contents, $edittable) {
                            $("input[name='" + this.id + "']").val(contents);
                        },
                        onImageUpload: function(files) {
                            var obj = this;
                            var data = new FormData();
                            data.append("file", files[0]);
                            $.ajax({
                                type: "post",
                                url: ctx + "common/upload",
                                data: data,
                                cache: false,
                                contentType: false,
                                processData: false,
                                dataType: 'json',
                                success: function(result) {
                                    if (result.code == web_status.SUCCESS) {
                                        $('#' + obj.id).summernote('insertImage', result.url);
                                    } else {
                                        $.modal.alertError(result.msg);
                                    }
                                },
                                error: function(error) {
                                    $.modal.alertWarning("图片上传失败。");
                                }
                            });
                        }
                    }
                });
                var content = $("input[name='" + this.id + "']").val();
                $('#' + this.id).summernote('code', content);
            })
        });
    </script>
</body>
</html>